import Cookies from 'js-cookie'

// 按钮权限
function checkPermission(el, binding) {
    // 获取按钮权限
    let actionList = Cookies.get('gn-actionList') ? Cookies.get('gn-actionList') : []
    let value = binding.value
    // 判断列表中是否有对应按钮权限标识
    let hasPermission = actionList.includes(value)
    if (!hasPermission) {
        el.style = 'display:none;'
        // 添加一个宏任务
        setTimeout(() => {
            el.parentNode.removeChild(el)
        }, 0);
    }
}

export default {
    beforeMount(el, binding) {
        checkPermission(el, binding)
    },
}